DEST = ./build/
CFLAGS = -O3 -fsingle-precision-constant -fPIC 
CFLAGS_ASM = -O2 -fsingle-precision-constant -fPIC
GENERAL_TWEAKS = -ffast-math -fgcse-lm -fgcse-sm -fsched-spec-load 
#==PC==
CPP = g++ -g -march=native -DX86CPU $(GENERAL_TWEAKS)
SDL = `sdl-config --cflags`
#==Consoles==
#==GP2X/WIZ==
#ORIGINALFW = -static -lfreetype -lpng -lpthread -lz -ljpeg -lm -s
ifeq ($(TARGET),gp2x)
CPP = /opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/arm-open2x-linux-g++ -DMOBILE_DEVICE -DARMCPU -DGP2X $(GENERAL_TWEAKS)
SDL = `/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/sdl-config --cflags`
INCLUDE = -I/opt/open2x/gcc-4.1.1-glibc-2.3.6/include
LIB = -L/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib -Wl,-rpath=/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib
endif
#==Caanoo==
ifeq ($(TARGET),caanoo)
CPP = /opt/caanoo/gcc-4.2.4-glibc-2.7-eabi/bin/arm-gph-linux-gnueabi-g++ -DMOBILE_DEVICE -DARMCPU -DCAANOO $(GENERAL_TWEAKS)
SDL = -I/opt/caanoo/gcc-4.2.4-glibc-2.7-eabi/arm-gph-linux-gnueabi/sys-root/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
INCLUDE = -I/opt/caanoo/gcc-4.2.4-glibc-2.7-eabi/arm-gph-linux-gnueabi/sys-root/usr/include
LIB = -L/opt/caanoo/gcc-4.2.4-glibc-2.7-eabi/arm-gph-linux-gnueabi/sys-root/usr/lib -Wl,-rpath=/opt/caanoo/gcc-4.2.4-glibc-2.7-eabi/arm-gph-linux-gnueabi/sys-root/usr/lib
endif
#==Dingoo==
ifeq ($(TARGET),dingoo)
CPP = /opt/mipsel-linux-uclibc/usr/bin/mipsel-linux-g++ -DDINGOO $(GENERAL_TWEAKS)
SDL = -I/opt/mipsel-linux-uclibc/usr/mipsel-linux-uclibc/sys-include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
INCLUDE = -I/opt/mipsel-linux-uclibc/usr/mipsel-linux-uclibc/sys-include
LIB = -L/opt/mipsel-linux-uclibc/usr/lib -Wl,-rpath=/opt/mipsel-linux-uclibc/usr/lib
endif
#==Pandora==
ifeq ($(TARGET),pandora)
CPP = /opt/pandora/arm-2011.03/bin/arm-none-linux-gnueabi-g++ -DARMCPU -DPANDORA $(GENERAL_TWEAKS)
SDL = `/opt/pandora/arm-2011.03/usr/bin/sdl-config --cflags`
INCLUDE = -I/opt/pandora/arm-2011.03/usr/include
LIB = -L/opt/pandora/arm-2011.03/usr/lib -Wl,-rpath=/opt/pandora/arm-2011.03/usr/lib -lpnd
endif

all: schizophrenia

targets:
	@echo "gp2x (=wiz), caanoo, dingoo, pandora"

schizophrenia: schizophrenia.cpp Physic.o Level.o SysUtils.o BaseUnit.o State.o SceneGraph.o DummySceneGraphElem.o SceneGraphElem.o SurfaceCache.o StateManager.o Input.o Sprite.o SurfaceSceneGraphElem.o stateManagerAsmStuff.o
	$(CPP) $(CFLAGS) Physic.o Level.o SysUtils.o schizophrenia.cpp BaseUnit.o State.o SceneGraph.o DummySceneGraphElem.o SceneGraphElem.o SurfaceCache.o StateManager.o Input.o Sprite.o SurfaceSceneGraphElem.o stateManagerAsmStuff.o $(SDL) $(INCLUDE) $(LIB) -lSDL_mixer -lSDL_image -lSDL -lm $(ORIGINALFW) -o $(DEST)schizophrenia

State.o: State.cpp State.hpp
	$(CPP) $(CFLAGS) -c State.cpp $(INCLUDE)

SceneGraph.o: SceneGraph.cpp SceneGraph.hpp
	$(CPP) $(CFLAGS) -c SceneGraph.cpp $(INCLUDE)

DummySceneGraphElem.o: DummySceneGraphElem.cpp DummySceneGraphElem.hpp
	$(CPP) $(CFLAGS) -c DummySceneGraphElem.cpp $(INCLUDE)

SceneGraphElem.o: SceneGraphElem.cpp SceneGraphElem.hpp
	$(CPP) $(CFLAGS) -c SceneGraphElem.cpp $(INCLUDE)

SurfaceCache.o: SurfaceCache.cpp SurfaceCache.hpp
	$(CPP) $(CFLAGS) -c SurfaceCache.cpp $(INCLUDE)

StateManager.o: StateManager.cpp StateManager.hpp
	$(CPP) $(CFLAGS) -c StateManager.cpp $(INCLUDE)

Input.o: Input.cpp Input.hpp
	$(CPP) $(CFLAGS) -c Input.cpp $(INCLUDE)

Sprite.o: Sprite.cpp Sprite.hpp
	$(CPP) $(CFLAGS) -c Sprite.cpp $(INCLUDE)

SurfaceSceneGraphElem.o: SurfaceSceneGraphElem.cpp SurfaceSceneGraphElem.hpp
	$(CPP) $(CFLAGS) -c SurfaceSceneGraphElem.cpp $(INCLUDE)

stateManagerAsmStuff.o: stateManagerAsmStuff.cpp StateManager.hpp
	$(CPP) $(CFLAGS_ASM) -c stateManagerAsmStuff.cpp $(INCLUDE)

BaseUnit.o: BaseUnit.cpp BaseUnit.hpp
	$(CPP) $(CFLAGS) -c BaseUnit.cpp $(INCLUDE)

SysUtils.o: SysUtils.cpp SysUtils.hpp
	$(CPP) $(CFLAGS) -c SysUtils.cpp $(INCLUDE)

Level.o: Level.cpp Level.hpp
	$(CPP) $(CFLAGS) -c Level.cpp $(INCLUDE)

Physic.o: Physic.cpp Physic.hpp
	$(CPP) $(CFLAGS) -c Physic.cpp $(INCLUDE)


clean:
	rm *.o
	rm ./build/schizophrenia

